<template>
	<view class="container">
		<view class="flex  withdraw_1">
			<view class="text">
				提现金额
			</view>
			<view class="flex money">
				<view class="" style="margin:0 10rpx 10rpx 0;">
					￥
				</view>
				<input class="input" type="number" v-model="money" />
			</view>
			<view class="kyye">
				可提现余额￥{{userInfo.money}}
			</view>
		</view>
		<view class="flex hcenter wcenter withdraw_2">
			<image src="/static/img/wxzf.png" style="width: 164rpx;height: 141rpx;" mode=""></image>

		</view>
		<view class="footer hcenter" @click="onwithdraw">
			提现
		</view>
		<view class="viewbottom" style="height: 166rpx;line-height:166rpx"></view>
	</view>
</template>


<script>
	import {
		withdraw,
	} from '@/api/user'
	import {
		useStore
	} from '@/store/index.js'
	import {
		onLoad,
		onUnload
	} from "@dcloudio/uni-app"
	import {
		reactive,
		toRefs,
		ref,
		watch,
		computed,
		onMounted,
	} from "vue"
	export default {
		setup() {
			const store = useStore()
			const state = reactive({
				userInfo: computed(() => store.userInfo),
				yuyuelist: [{}, {}, {}],
				pinlunlist: [{}, {}],
				id: '',
				title: '',
				num: 1,
				money: ""
			})
			onLoad((option) => {
				console.log(option);
				getData()
				uni.setNavigationBarTitle({
					title: '提现',
				})
			})

			const getData = async () => {


			}
			const onwithdraw = async () => {
				if (state.money=='' || state.money==0) return;
				if (Number(state.money) > Number(state.userInfo.money)) {
					uni.showToast({
						title: "提现金额错误",
						icon: 'none',
					})
					return;
				}
				withdraw({money:state.money}).then(res=>{
					
				});
			}
			return {
				...toRefs(state),
				onwithdraw,
			}
		}

	}
</script>
<style>
	page {
		background-color: #EFEFEF;
	}
</style>
<style lang="scss" scoped>
	/* #ifdef H5 */
	page {
		height: auto;
		min-height: 100%;
	}

	/* #endif */
	.container {
		min-height: 100%;
		// background: rgb(244, 244, 244);
	}

	.footer {
		position: fixed;
		/* 固定定位 */
		bottom: 0;
		/* 底部对齐 */
		width: 100%;
		/* 宽度100% */
		display: flex;
		/* 使用Flex布局 */
		height: 88rpx;
		background-color: #00be4c;
		justify-content: space-around;
		color: #fff
	}

	.withdraw_1 {
		flex-direction: column;
		background-color: #fff;
		padding: 48rpx 45rpx 35rpx 45rpx;

		.input {
			font-size: 60rpx;
		}

		.text {
			color: #a9a9a9;
			margin-bottom: 20rpx;
		}

		.money {
			align-items: flex-end;
			border-bottom: 2rpx solid #ccc;
		}

		.kyye {
			margin-top: 10rpx;
			color: #aaa;
		}
	}

	.withdraw_2 {
		margin-top: 20rpx;
		padding: 66rpx 0 36rpx 0;
		background-color: #fff;
	}
</style>